/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * frmMantenerOdontologo.java
 *
 * Created on 27/11/2011, 03:37:43 PM
 */
package pe.sonrisas.tools.view;

import Complementos.Validar;
import Complementos.Visual;
import Control.ControlHorarioOdontologo;
import Control.ControlOdontologo;
import Control.ControlPersona;
import Control.ControlUbigeo;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import javax.swing.JOptionPane;

/**
 *
 * @author DIEGOALV
 */
public class frmMantenerOdontologo extends javax.swing.JFrame {

    /**
     * Creates new form frmMantenerOdontologo
     */
    Validar validar = new Validar();
    String fechaingreso = "";
    static private frmMantenerOdontologo objeto = null;

    public frmMantenerOdontologo() {
        initComponents();
        cargarComboDeptos();
        valoresPorDefecto();

    }

    static public frmMantenerOdontologo getInstancia() {
        if (objeto == null) {
            objeto = new frmMantenerOdontologo();
        }
        return objeto;
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tbPaneOdontologo = new javax.swing.JTabbedPane();
        panel = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        txtNombres = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        txtApellidoPaterno = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        txtDni = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        txtDireccion = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        txtTel = new javax.swing.JTextField();
        comboDepto = new javax.swing.JComboBox();
        comboProvincia = new javax.swing.JComboBox();
        jLabel21 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        comboDistrito = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        txtEdad = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        txtCelular = new javax.swing.JTextField();
        txtEmail = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        txtNacionalidad = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        txtCMP = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        txtEspecialidad = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        txtFacultad = new javax.swing.JTextField();
        btnRegistrar = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        rbtMasculino = new javax.swing.JRadioButton();
        rbtFemenino = new javax.swing.JRadioButton();
        jLabel18 = new javax.swing.JLabel();
        txtApellidoMaterno = new javax.swing.JTextField();
        comboFecha = new datechooser.beans.DateChooserCombo();
        jPanel2 = new javax.swing.JPanel();
        chkLun = new javax.swing.JCheckBox();
        chkMar = new javax.swing.JCheckBox();
        chkMier = new javax.swing.JCheckBox();
        chkJue = new javax.swing.JCheckBox();
        chkVier = new javax.swing.JCheckBox();
        chkSab = new javax.swing.JCheckBox();
        jLabel14 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        chkDom = new javax.swing.JCheckBox();
        comboDesdeLunes = new javax.swing.JComboBox();
        comboHastaLunes = new javax.swing.JComboBox();
        comboDesdeMartes = new javax.swing.JComboBox();
        comboHastaMartes = new javax.swing.JComboBox();
        comboDesdeMier = new javax.swing.JComboBox();
        comboHastaMier = new javax.swing.JComboBox();
        comboDesdeJu = new javax.swing.JComboBox();
        comboHastaJu = new javax.swing.JComboBox();
        comboDesdeViernes = new javax.swing.JComboBox();
        comboHastaVier = new javax.swing.JComboBox();
        comboDesdeSab = new javax.swing.JComboBox();
        comboHastaSab = new javax.swing.JComboBox();
        comboDesdeDomingo = new javax.swing.JComboBox();
        comboHastaDomingo = new javax.swing.JComboBox();
        btnRegistrarHorario = new javax.swing.JButton();
        jLabel17 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("..:: Consultorio Sonrisas :..    Mantenimiento Odontólogo");

        panel.setBackground(new java.awt.Color(204, 204, 240));

        jLabel1.setText("Nombres:");

        txtNombres.setAutoscrolls(false);
        txtNombres.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtNombresKeyPressed(evt);
            }
        });

        jLabel2.setText("Apellido Paterno:");

        txtApellidoPaterno.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtApellidoPaternoKeyPressed(evt);
            }
        });

        jLabel3.setText("DNI:");

        txtDni.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtDniKeyPressed(evt);
            }
        });

        jLabel4.setText("Dirección:");

        txtDireccion.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtDireccionKeyPressed(evt);
            }
        });

        jLabel5.setText("Teléfono:");

        txtTel.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtTelKeyPressed(evt);
            }
        });

        comboDepto.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                comboDeptoItemStateChanged(evt);
            }
        });

        comboProvincia.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                comboProvinciaItemStateChanged(evt);
            }
        });

        jLabel21.setText("Provincia:");

        jLabel15.setText("Distrito:");

        jLabel7.setText("Fecha Nac:");

        jLabel8.setText("Edad:");

        txtEdad.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtEdadKeyPressed(evt);
            }
        });

        jLabel6.setText("Celular:");

        txtCelular.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtCelularKeyPressed(evt);
            }
        });

        txtEmail.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtEmailKeyPressed(evt);
            }
        });

        jLabel11.setText("Email:");

        jLabel24.setText("Nacionalidad:");

        txtNacionalidad.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtNacionalidadKeyPressed(evt);
            }
        });

        jLabel19.setText("Departamento:");

        jLabel9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pe/sonrisas/tools/imagenes/comun/agregarOdontologo2.png"))); // NOI18N

        txtCMP.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtCMPKeyPressed(evt);
            }
        });

        jLabel10.setText("CMP:");

        txtEspecialidad.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtEspecialidadKeyPressed(evt);
            }
        });

        jLabel12.setText("Especialidad:");

        jLabel13.setText("Facultad:");

        btnRegistrar.setText("Registrar odontólogo");
        btnRegistrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRegistrarActionPerformed(evt);
            }
        });

        jPanel3.setBackground(new java.awt.Color(204, 204, 240));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 204)), "Género"));

        rbtMasculino.setBackground(new java.awt.Color(204, 204, 255));
        rbtMasculino.setText("Masculino");
        rbtMasculino.setActionCommand("M");

        rbtFemenino.setBackground(new java.awt.Color(204, 204, 255));
        rbtFemenino.setText("Femenino");
        rbtFemenino.setActionCommand("F");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rbtMasculino)
                .addGap(18, 18, 18)
                .addComponent(rbtFemenino)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rbtMasculino)
                    .addComponent(rbtFemenino))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel18.setText("Apellido Materno:");

        txtApellidoMaterno.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtApellidoMaternoKeyPressed(evt);
            }
        });

        comboFecha.setCurrentView(new datechooser.view.appearance.AppearancesList("Grey",
            new datechooser.view.appearance.ViewAppearance("custom",
                new datechooser.view.appearance.swing.SwingCellAppearance(new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11),
                    new java.awt.Color(0, 0, 0),
                    new java.awt.Color(0, 0, 255),
                    false,
                    true,
                    new datechooser.view.appearance.swing.ButtonPainter()),
                new datechooser.view.appearance.swing.SwingCellAppearance(new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11),
                    new java.awt.Color(0, 0, 0),
                    new java.awt.Color(0, 0, 255),
                    true,
                    true,
                    new datechooser.view.appearance.swing.ButtonPainter()),
                new datechooser.view.appearance.swing.SwingCellAppearance(new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11),
                    new java.awt.Color(0, 0, 255),
                    new java.awt.Color(0, 0, 255),
                    false,
                    true,
                    new datechooser.view.appearance.swing.ButtonPainter()),
                new datechooser.view.appearance.swing.SwingCellAppearance(new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11),
                    new java.awt.Color(128, 128, 128),
                    new java.awt.Color(0, 0, 255),
                    false,
                    true,
                    new datechooser.view.appearance.swing.LabelPainter()),
                new datechooser.view.appearance.swing.SwingCellAppearance(new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11),
                    new java.awt.Color(0, 0, 0),
                    new java.awt.Color(0, 0, 255),
                    false,
                    true,
                    new datechooser.view.appearance.swing.LabelPainter()),
                new datechooser.view.appearance.swing.SwingCellAppearance(new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11),
                    new java.awt.Color(0, 0, 0),
                    new java.awt.Color(255, 0, 0),
                    false,
                    false,
                    new datechooser.view.appearance.swing.ButtonPainter()),
                (datechooser.view.BackRenderer)null,
                false,
                true)));
    comboFecha.setFormat(2);
    comboFecha.setLocale(new java.util.Locale("es", "PE", ""));
    comboFecha.setBehavior(datechooser.model.multiple.MultyModelBehavior.SELECT_SINGLE);
    comboFecha.addSelectionChangedListener(new datechooser.events.SelectionChangedListener() {
        public void onSelectionChange(datechooser.events.SelectionChangedEvent evt) {
            comboFechaOnSelectionChange(evt);
        }
    });

    javax.swing.GroupLayout panelLayout = new javax.swing.GroupLayout(panel);
    panel.setLayout(panelLayout);
    panelLayout.setHorizontalGroup(
        panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelLayout.createSequentialGroup()
            .addGap(16, 16, 16)
            .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jLabel11)
                        .addComponent(jLabel24)
                        .addComponent(jLabel5)
                        .addComponent(jLabel6)
                        .addComponent(jLabel4)
                        .addComponent(jLabel3)
                        .addComponent(jLabel2))
                    .addComponent(jLabel18))
                .addComponent(jLabel1))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(txtNacionalidad, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(panelLayout.createSequentialGroup()
                    .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
                            .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGroup(panelLayout.createSequentialGroup()
                            .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(txtApellidoMaterno)
                                    .addComponent(txtApellidoPaterno, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)
                                    .addComponent(txtCelular, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)
                                    .addComponent(txtTel, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)
                                    .addComponent(txtDireccion, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)
                                    .addComponent(txtDni, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE))
                                .addComponent(txtNombres, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                    .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
                                .addGap(44, 44, 44)
                                .addComponent(jLabel21))
                            .addGroup(panelLayout.createSequentialGroup()
                                .addGap(37, 37, 37)
                                .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel7)
                                    .addComponent(jLabel8)
                                    .addComponent(jLabel15))))
                        .addComponent(jLabel19)
                        .addComponent(jLabel10)
                        .addComponent(jLabel12)
                        .addComponent(jLabel13))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(comboDistrito, javax.swing.GroupLayout.Alignment.LEADING, 0, 155, Short.MAX_VALUE)
                            .addComponent(comboProvincia, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(comboDepto, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(txtFacultad, javax.swing.GroupLayout.Alignment.LEADING))
                        .addComponent(txtEdad, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(txtEspecialidad, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtCMP, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE))
                        .addComponent(comboFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(panelLayout.createSequentialGroup()
                            .addGap(65, 65, 65)
                            .addComponent(btnRegistrar))
                        .addGroup(panelLayout.createSequentialGroup()
                            .addGap(73, 73, 73)
                            .addComponent(jLabel9)))))
            .addContainerGap())
    );
    panelLayout.setVerticalGroup(
        panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(panelLayout.createSequentialGroup()
            .addGap(24, 24, 24)
            .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addGroup(panelLayout.createSequentialGroup()
                    .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(comboDepto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel19)
                        .addComponent(txtApellidoPaterno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel2))
                    .addGap(18, 18, 18)
                    .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel21)
                        .addComponent(comboProvincia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(txtApellidoMaterno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel18))
                    .addGap(18, 18, 18)
                    .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel15)
                        .addComponent(comboDistrito, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel1)
                        .addComponent(txtNombres, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(22, 22, 22)
                    .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(txtDni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))
                        .addComponent(comboFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(18, 18, 18)
                    .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel8)
                        .addComponent(txtEdad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(txtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel4)))
                .addComponent(jLabel9))
            .addGap(18, 18, 18)
            .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(txtCMP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel10)
                .addComponent(btnRegistrar)
                .addComponent(txtTel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel5))
            .addGap(18, 18, 18)
            .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(txtEspecialidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel12)
                .addComponent(txtCelular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel6))
            .addGap(18, 18, 18)
            .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel13)
                .addComponent(txtFacultad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel11))
            .addGap(18, 18, 18)
            .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(txtNacionalidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel24))
            .addGap(14, 14, 14)
            .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(51, 51, 51))
    );

    tbPaneOdontologo.addTab("Registrar odontólogo", panel);

    jPanel2.setBackground(new java.awt.Color(204, 204, 240));

    chkLun.setText("Lunes");
    chkLun.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            chkLunActionPerformed(evt);
        }
    });

    chkMar.setText("Martes");
    chkMar.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            chkMarActionPerformed(evt);
        }
    });

    chkMier.setText("Miércoles");
    chkMier.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            chkMierActionPerformed(evt);
        }
    });

    chkJue.setText("Jueves");
    chkJue.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            chkJueActionPerformed(evt);
        }
    });

    chkVier.setText("Viernes");
    chkVier.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            chkVierActionPerformed(evt);
        }
    });

    chkSab.setText("Sábado");
    chkSab.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            chkSabActionPerformed(evt);
        }
    });

    jLabel14.setText("Desde");

    jLabel16.setText("Hasta");

    chkDom.setText("Domingo");
    chkDom.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            chkDomActionPerformed(evt);
        }
    });

    comboDesdeLunes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }));
    comboDesdeLunes.setEnabled(false);

    comboHastaLunes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }));
    comboHastaLunes.setEnabled(false);

    comboDesdeMartes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }));
    comboDesdeMartes.setEnabled(false);

    comboHastaMartes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }));
    comboHastaMartes.setEnabled(false);

    comboDesdeMier.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }));
    comboDesdeMier.setEnabled(false);

    comboHastaMier.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }));
    comboHastaMier.setEnabled(false);

    comboDesdeJu.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }));
    comboDesdeJu.setEnabled(false);

    comboHastaJu.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }));
    comboHastaJu.setEnabled(false);

    comboDesdeViernes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }));
    comboDesdeViernes.setEnabled(false);

    comboHastaVier.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }));
    comboHastaVier.setEnabled(false);

    comboDesdeSab.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }));
    comboDesdeSab.setEnabled(false);

    comboHastaSab.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }));
    comboHastaSab.setEnabled(false);

    comboDesdeDomingo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }));
    comboDesdeDomingo.setEnabled(false);

    comboHastaDomingo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }));
    comboHastaDomingo.setEnabled(false);

    btnRegistrarHorario.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pe/sonrisas/tools/imagenes/comun/horario.png"))); // NOI18N
    btnRegistrarHorario.setText("Registrar horario");
    btnRegistrarHorario.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnRegistrarHorarioActionPerformed(evt);
        }
    });

    jLabel17.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pe/sonrisas/tools/imagenes/comun/doctor.png"))); // NOI18N

    javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(
        jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel2Layout.createSequentialGroup()
            .addGap(20, 20, 20)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(chkSab)
                .addComponent(chkVier)
                .addComponent(chkJue)
                .addComponent(chkMier)
                .addComponent(chkMar)
                .addComponent(chkLun)
                .addComponent(chkDom))
            .addGap(63, 63, 63)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jLabel14)
                .addComponent(comboDesdeLunes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(comboDesdeMartes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(comboDesdeMier, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(comboDesdeJu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(comboDesdeViernes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(comboDesdeSab, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(comboDesdeDomingo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(46, 46, 46)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup()
                    .addComponent(btnRegistrarHorario)
                    .addContainerGap(607, Short.MAX_VALUE))
                .addGroup(jPanel2Layout.createSequentialGroup()
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(comboHastaDomingo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(comboHastaLunes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(comboHastaSab, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(comboHastaVier, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(comboHastaJu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(comboHastaMier, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(comboHastaMartes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel16))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel17)
                    .addGap(78, 78, 78))))
    );
    jPanel2Layout.setVerticalGroup(
        jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel2Layout.createSequentialGroup()
            .addGap(34, 34, 34)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel14)
                .addComponent(jLabel16))
            .addGap(17, 17, 17)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(chkLun)
                .addComponent(comboDesdeLunes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(comboHastaLunes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(18, 18, 18)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(chkMar)
                .addComponent(comboDesdeMartes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(comboHastaMartes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(18, 18, 18)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(chkMier)
                .addComponent(comboDesdeMier, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(comboHastaMier, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(18, 18, 18)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(chkJue)
                .addComponent(comboDesdeJu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(comboHastaJu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(18, 18, 18)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(chkVier)
                .addComponent(comboDesdeViernes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(comboHastaVier, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(18, 18, 18)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(chkSab)
                .addComponent(comboDesdeSab, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(comboHastaSab, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(18, 18, 18)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(chkDom)
                .addComponent(comboDesdeDomingo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(comboHastaDomingo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(46, 46, 46)
            .addComponent(btnRegistrarHorario)
            .addContainerGap(62, Short.MAX_VALUE))
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jLabel17)
            .addGap(121, 121, 121))
    );

    tbPaneOdontologo.addTab("Horario de trabajo", jPanel2);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(tbPaneOdontologo)
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(tbPaneOdontologo)
    );

    pack();
    }// </editor-fold>//GEN-END:initComponents

    private void txtNombresKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNombresKeyPressed

        if ((evt.getKeyCode() == KeyEvent.VK_ENTER)) {
            if (validar.esVacio(txtNombres.getText())) {
                JOptionPane.showMessageDialog(this, "Debe ingresar un nombre", "Campo obligatorio", JOptionPane.ERROR_MESSAGE);
                txtNombres.requestFocus();
                System.out.print(validar.validarTexto(txtNombres.getText()));
            } else if (validar.validarTexto(txtNombres.getText())) {


                txtDni.requestFocus();
            } else {
                JOptionPane.showMessageDialog(this, "El nombre no debe contener numeros/símbolos", "Error", JOptionPane.ERROR_MESSAGE);
                txtNombres.requestFocus();
                txtNombres.selectAll();
            }
        }
}//GEN-LAST:event_txtNombresKeyPressed

    private void txtApellidoPaternoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtApellidoPaternoKeyPressed
        if (evt.getKeyCode() == evt.VK_ENTER) {
            if (validar.esVacio(txtApellidoPaterno.getText())) {
                JOptionPane.showMessageDialog(this, "Debe ingresar apellidos", "Campo obligatorio", JOptionPane.ERROR_MESSAGE);
                txtApellidoPaterno.requestFocus();
            } else if (validar.validarTexto(txtApellidoPaterno.getText())) {
                txtApellidoMaterno.requestFocus();
            } else {
                JOptionPane.showMessageDialog(this, "El apellido no debe contener numeros/símbolos", "Error", JOptionPane.ERROR_MESSAGE);
                txtApellidoPaterno.requestFocus();
                txtApellidoPaterno.selectAll();
            }
        }
}//GEN-LAST:event_txtApellidoPaternoKeyPressed

    private void txtDniKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDniKeyPressed
        if (evt.getKeyCode() == evt.VK_ENTER) {
            if (validar.validarDni(txtDni.getText())) {
                txtDireccion.requestFocus();
            } else {
                JOptionPane.showMessageDialog(this, "DNI incorrecto, sólo debe contener numeros y no debe superar los 8 dígitos", "Error", JOptionPane.ERROR_MESSAGE);
                txtDni.requestFocus();
                txtDni.selectAll();
            }
        }
}//GEN-LAST:event_txtDniKeyPressed

    private void txtDireccionKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDireccionKeyPressed
       if (evt.getKeyCode() == evt.VK_ENTER) {
            if (validar.esVacio(txtDireccion.getText())) {
                JOptionPane.showMessageDialog(this, "Debe ingresar direccion", "Campo obligatorio", JOptionPane.ERROR_MESSAGE);
                txtDireccion.requestFocus();
            } else if (validar.validarTexto(txtDireccion.getText())) {
                txtTel.requestFocus();
            } else {
                JOptionPane.showMessageDialog(this, "El apellido no debe contener numeros/símbolos", "Error", JOptionPane.ERROR_MESSAGE);
                txtDireccion.requestFocus();
                txtDireccion.selectAll();
            }
        }


}//GEN-LAST:event_txtDireccionKeyPressed

    private void txtTelKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtTelKeyPressed
        if (evt.getKeyCode() == evt.VK_ENTER) {
            if (validar.validarTelefono(txtTel.getText())) {
                txtCelular.requestFocus();
            } else {
                JOptionPane.showMessageDialog(this, "El teléfono sólo debe contener numeros", "Error", JOptionPane.ERROR_MESSAGE);
                txtTel.requestFocus();
                txtTel.selectAll();
            }
        }
}//GEN-LAST:event_txtTelKeyPressed

    private void comboDeptoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_comboDeptoItemStateChanged
        comboProvincia.removeAllItems();
        int cod = comboDepto.getSelectedIndex();
        cargarComboProvincias(cod);
}//GEN-LAST:event_comboDeptoItemStateChanged

    private void comboProvinciaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_comboProvinciaItemStateChanged
        comboDistrito.removeAllItems();
        int codD = comboDepto.getSelectedIndex();
        int codP = comboProvincia.getSelectedIndex();
        cargarComboDistritos(codD, codP);
}//GEN-LAST:event_comboProvinciaItemStateChanged

    private void txtEdadKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtEdadKeyPressed
}//GEN-LAST:event_txtEdadKeyPressed

    private void txtCelularKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtCelularKeyPressed
        if (evt.getKeyCode() == evt.VK_ENTER) {
            if (validar.validarCelular(txtCelular.getText())) {
                txtEmail.requestFocus();
            } else {
                JOptionPane.showMessageDialog(this, "El celular sólo debe contener numeros y no debe superar los 9 dígitos", "Error", JOptionPane.ERROR_MESSAGE);
                txtCelular.requestFocus();
                txtCelular.selectAll();
            }
        }
}//GEN-LAST:event_txtCelularKeyPressed

    private void txtEmailKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtEmailKeyPressed
        if (evt.getKeyCode() == evt.VK_ENTER) {
            if (txtEmail.getText().equals("")) {
                txtNacionalidad.requestFocus();
            } else if (validar.validarEmail(txtEmail.getText())) {
                txtNacionalidad.requestFocus();
            } else {
                JOptionPane.showMessageDialog(this, "Email incorrecto", "Error", JOptionPane.ERROR_MESSAGE);
                txtEmail.requestFocus();
                txtEmail.selectAll();
            }
        }
}//GEN-LAST:event_txtEmailKeyPressed

    private void txtNacionalidadKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNacionalidadKeyPressed
        if (evt.getKeyCode() == evt.VK_ENTER) {
            if (validar.validarTexto(txtNacionalidad.getText())) {
                comboDepto.requestFocus();
            } else {
                JOptionPane.showMessageDialog(this, "La nacionalidad no debe contener numeros/símbolos", "Error", JOptionPane.ERROR_MESSAGE);
                txtNacionalidad.requestFocus();
                txtNacionalidad.selectAll();
            }
        }
}//GEN-LAST:event_txtNacionalidadKeyPressed

    private void btnRegistrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegistrarActionPerformed
        char genero;
        char grupo;
        if (rbtMasculino.isSelected()) {
            genero = rbtMasculino.getActionCommand().charAt(0);
        } else {
            genero = rbtFemenino.getActionCommand().charAt(0);
        }

        ControlUbigeo ubigeo = new ControlUbigeo();
        int idubigeo = ubigeo.dameIdUbigeo(comboDepto.getSelectedIndex() + 1, comboProvincia.getSelectedIndex() + 1, comboDistrito.getSelectedIndex() + 1);


        ControlPersona controlPersona = new ControlPersona();
        String fecha = validar.cambiarFormatoFechaParaBD(comboFecha.getText());
        controlPersona.agregarPersona(txtNombres.getText(), txtApellidoPaterno.getText(), txtApellidoMaterno.getText(), txtDni.getText(), txtNacionalidad.getText(), txtDireccion.getText(), txtEmail.getText(), txtTel.getText(), txtCelular.getText(), fecha, genero, idubigeo);

        ControlOdontologo controlOdonto = new ControlOdontologo();
        controlOdonto.agregarOdontologo(Integer.parseInt(txtCMP.getText()), controlPersona.cargarCodigo(), txtEspecialidad.getText(), txtFacultad.getText(), fechaingreso);

        JOptionPane.showMessageDialog(this, "Se ha registrado el odontologo en el sistema. Por favor registre ahora su horario de trabajo", "Registro completo", JOptionPane.INFORMATION_MESSAGE);
        tbPaneOdontologo.setSelectedIndex(1);


    }//GEN-LAST:event_btnRegistrarActionPerformed

    private void txtCMPKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtCMPKeyPressed
        if (evt.getKeyCode() == evt.VK_ENTER) {
            if (validar.validarNro(txtCMP.getText())) {
                txtEspecialidad.requestFocus();
            } else {
                JOptionPane.showMessageDialog(this, "El CMP sólo debe contener numeros", "Error", JOptionPane.ERROR_MESSAGE);
                txtCMP.requestFocus();
                txtCMP.selectAll();
            }
        }
    }//GEN-LAST:event_txtCMPKeyPressed

    private void txtEspecialidadKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtEspecialidadKeyPressed
        if (evt.getKeyCode() == evt.VK_ENTER) {
            txtFacultad.requestFocus();
        }
    }//GEN-LAST:event_txtEspecialidadKeyPressed

    private void chkLunActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkLunActionPerformed

        if (chkLun.isSelected()) {
            comboDesdeLunes.setEnabled(true);
            comboHastaLunes.setEnabled(true);
            comboDesdeLunes.requestFocus();
        } else {
            comboDesdeLunes.setEnabled(false);
            comboHastaLunes.setEnabled(false);
        }
    }//GEN-LAST:event_chkLunActionPerformed

    private void chkMarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkMarActionPerformed
        if (chkMar.isSelected()) {
            comboDesdeMartes.setEnabled(true);
            comboHastaMartes.setEnabled(true);
            comboDesdeMartes.requestFocus();
        } else {
            comboDesdeMartes.setEnabled(false);
            comboHastaMartes.setEnabled(false);
        }
    }//GEN-LAST:event_chkMarActionPerformed

    private void chkMierActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkMierActionPerformed
        if (chkMier.isSelected()) {
            comboDesdeMier.setEnabled(true);
            comboHastaMier.setEnabled(true);
            comboDesdeMier.requestFocus();
        } else {
            comboDesdeMier.setEnabled(false);
            comboHastaMier.setEnabled(false);
        }
    }//GEN-LAST:event_chkMierActionPerformed

    private void chkJueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkJueActionPerformed
        if (chkJue.isSelected()) {
            comboDesdeJu.setEnabled(true);
            comboHastaJu.setEnabled(true);
            comboDesdeJu.requestFocus();
        } else {
            comboDesdeJu.setEnabled(false);
            comboHastaJu.setEnabled(false);
        }
    }//GEN-LAST:event_chkJueActionPerformed

    private void chkVierActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkVierActionPerformed
        if (chkVier.isSelected()) {
            comboDesdeViernes.setEnabled(true);
            comboHastaVier.setEnabled(true);
            comboDesdeViernes.requestFocus();
        } else {
            comboDesdeViernes.setEnabled(false);
            comboHastaVier.setEnabled(false);
        }
    }//GEN-LAST:event_chkVierActionPerformed

    private void chkSabActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkSabActionPerformed
        if (chkSab.isSelected()) {
            comboDesdeSab.setEnabled(true);
            comboHastaSab.setEnabled(true);
            comboDesdeSab.requestFocus();
        } else {
            comboDesdeSab.setEnabled(false);
            comboHastaSab.setEnabled(false);
        }

    }//GEN-LAST:event_chkSabActionPerformed

    private void chkDomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkDomActionPerformed
        if (chkDom.isSelected()) {
            comboDesdeDomingo.setEnabled(true);
            comboHastaDomingo.setEnabled(true);
            comboDesdeDomingo.requestFocus();
        } else {
            comboDesdeDomingo.setEnabled(false);
            comboHastaDomingo.setEnabled(false);
        }
    }//GEN-LAST:event_chkDomActionPerformed

    private void btnRegistrarHorarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegistrarHorarioActionPerformed
        ControlHorarioOdontologo controlHorario = new ControlHorarioOdontologo();

        if (chkLun.isSelected()) {
            controlHorario.agregarHorario(2, comboDesdeLunes.getSelectedItem().toString() + ":" + "00", comboHastaLunes.getSelectedItem().toString() + ":" + "00");
        }

        if (chkMar.isSelected()) {
            controlHorario.agregarHorario(3, comboDesdeMartes.getSelectedItem().toString() + ":" + "00", comboHastaMartes.getSelectedItem().toString() + ":" + "00");
        }

        if (chkMier.isSelected()) {
            controlHorario.agregarHorario(4,  comboDesdeMier.getSelectedItem().toString() + ":" + "00", comboHastaMier.getSelectedItem().toString() + ":" + "00");
        }

        if (chkJue.isSelected()) {
            controlHorario.agregarHorario(5,  comboDesdeJu.getSelectedItem().toString() + ":" + "00", comboHastaJu.getSelectedItem().toString() + ":" + "00");
        }


        if (chkVier.isSelected()) {
            controlHorario.agregarHorario(6,  comboDesdeViernes.getSelectedItem().toString() + ":" + "00", comboHastaVier.getSelectedItem().toString() + ":" + "00");
        }

        if (chkSab.isSelected()) {
            controlHorario.agregarHorario(7,  comboDesdeSab.getSelectedItem().toString() + ":" + "00", comboHastaSab.getSelectedItem().toString() + ":" + "00");
        }

        if (chkDom.isSelected()) {
            controlHorario.agregarHorario(1,  comboDesdeDomingo.getSelectedItem().toString() + ":" + "00", comboHastaDomingo.getSelectedItem().toString() + ":" + "00");
        }

        JOptionPane.showMessageDialog(this, "Se registrado el horario de trabajo", "Registro completo", JOptionPane.INFORMATION_MESSAGE);
        int resp = JOptionPane.showConfirmDialog(this, "¿Desea registrar otro odontólogo?", "Nuevo registro", JOptionPane.YES_NO_OPTION);

        if (resp == 0) {
            limpiarVentana();
            tbPaneOdontologo.setSelectedIndex(0);
        } else {
            dispose();
        }
    }//GEN-LAST:event_btnRegistrarHorarioActionPerformed

    private void txtApellidoMaternoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtApellidoMaternoKeyPressed
       if (evt.getKeyCode() == evt.VK_ENTER) {
            if (validar.esVacio(txtApellidoMaterno.getText())) {
                JOptionPane.showMessageDialog(this, "Debe ingresar apellidos", "Campo obligatorio", JOptionPane.ERROR_MESSAGE);
                txtApellidoMaterno.requestFocus();
            } else if (validar.validarTexto(txtApellidoPaterno.getText())) {
                txtNombres.requestFocus();
            } else {
                JOptionPane.showMessageDialog(this, "El apellido no debe contener numeros/símbolos", "Error", JOptionPane.ERROR_MESSAGE);
                txtApellidoMaterno.requestFocus();
                txtApellidoMaterno.selectAll();
            }
        }
    }//GEN-LAST:event_txtApellidoMaternoKeyPressed

    private void comboFechaOnSelectionChange(datechooser.events.SelectionChangedEvent evt) {//GEN-FIRST:event_comboFechaOnSelectionChange
         int edad = validar.calcularEdad(comboFecha.getText());
         txtEdad.setText(""+edad);   
    }//GEN-LAST:event_comboFechaOnSelectionChange

    public final void cargarComboDeptos() {
        ControlUbigeo control = new ControlUbigeo();
        ArrayList<ArrayList> listado = control.listarDeptos();

        for (int i = 0; i < listado.size(); i++) {
            comboDepto.addItem(listado.get(i).get(1).toString());
        }
    }

    public void cargarComboProvincias(int cod) {

        ControlUbigeo control = new ControlUbigeo();
        ArrayList<ArrayList> listado = control.listarProvincias(cod + 1);

        for (int i = 0; i < listado.size(); i++) {
            comboProvincia.addItem(listado.get(i).get(0).toString());


        }
    }

    public void cargarComboDistritos(int codDepto, int codProv) {
        ControlUbigeo control = new ControlUbigeo();
        ArrayList<ArrayList> listado = control.listarDistritos(codDepto + 1, codProv + 1);

        for (int i = 0; i < listado.size(); i++) {
            comboDistrito.addItem(listado.get(i).get(0).toString());


        }

    }

    public final void valoresPorDefecto() {
        rbtMasculino.setSelected(true);
        txtApellidoPaterno.requestFocus();
        fechaingreso = validar.cambiarFormatoFechaParaBD(comboFecha.getText());    

    }

    public void limpiarVentana() {
        txtNombres.setText("");
        txtApellidoPaterno.setText("");
        txtApellidoMaterno.setText(""); 
        txtDni.setText("");
        txtNacionalidad.setText("");
        txtDireccion.setText("");
        txtTel.setText("");
        txtCelular.setText("");
        txtEdad.setText("");
        txtEmail.setText("");
        txtCMP.setText("");
        txtEspecialidad.setText("");
        txtFacultad.setText("");
        rbtMasculino.setSelected(true);
        txtNombres.requestFocus();
        comboFecha.setText(fechaingreso);

        chkLun.setSelected(false);
        chkMar.setSelected(false);
        chkMier.setSelected(false);
        chkJue.setSelected(false);
        chkVier.setSelected(false);
        chkSab.setSelected(false);
        chkDom.setSelected(false);




        comboDesdeLunes.setSelectedIndex(0);
        comboDesdeMartes.setSelectedIndex(0);
        comboDesdeMier.setSelectedIndex(0);
        comboDesdeJu.setSelectedIndex(0);
        comboDesdeViernes.setSelectedIndex(0);
        comboDesdeSab.setSelectedIndex(0);
        comboDesdeDomingo.setSelectedIndex(0);

        comboHastaLunes.setSelectedIndex(0);
        comboHastaMartes.setSelectedIndex(0);
        comboHastaMier.setSelectedIndex(0);
        comboHastaJu.setSelectedIndex(0);
        comboHastaVier.setSelectedIndex(0);
        comboHastaSab.setSelectedIndex(0);
        comboHastaDomingo.setSelectedIndex(0);

        comboDesdeLunes.setEnabled(false);
        comboDesdeMartes.setEnabled(false);
        comboDesdeMier.setEnabled(false);
        comboDesdeJu.setEnabled(false);
        comboDesdeViernes.setEnabled(false);
        comboDesdeSab.setEnabled(false);
        comboDesdeDomingo.setEnabled(false);

        comboHastaLunes.setEnabled(false);
        comboHastaMartes.setEnabled(false);
        comboHastaMier.setEnabled(false);
        comboHastaJu.setEnabled(false);
        comboHastaVier.setEnabled(false);
        comboHastaSab.setEnabled(false);
        comboHastaDomingo.setEnabled(false);









    }

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                Visual.aspectoMac();
                new frmMantenerOdontologo().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnRegistrar;
    private javax.swing.JButton btnRegistrarHorario;
    private javax.swing.JCheckBox chkDom;
    private javax.swing.JCheckBox chkJue;
    private javax.swing.JCheckBox chkLun;
    private javax.swing.JCheckBox chkMar;
    private javax.swing.JCheckBox chkMier;
    private javax.swing.JCheckBox chkSab;
    private javax.swing.JCheckBox chkVier;
    private javax.swing.JComboBox comboDepto;
    private javax.swing.JComboBox comboDesdeDomingo;
    private javax.swing.JComboBox comboDesdeJu;
    private javax.swing.JComboBox comboDesdeLunes;
    private javax.swing.JComboBox comboDesdeMartes;
    private javax.swing.JComboBox comboDesdeMier;
    private javax.swing.JComboBox comboDesdeSab;
    private javax.swing.JComboBox comboDesdeViernes;
    private javax.swing.JComboBox comboDistrito;
    private datechooser.beans.DateChooserCombo comboFecha;
    private javax.swing.JComboBox comboHastaDomingo;
    private javax.swing.JComboBox comboHastaJu;
    private javax.swing.JComboBox comboHastaLunes;
    private javax.swing.JComboBox comboHastaMartes;
    private javax.swing.JComboBox comboHastaMier;
    private javax.swing.JComboBox comboHastaSab;
    private javax.swing.JComboBox comboHastaVier;
    private javax.swing.JComboBox comboProvincia;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel panel;
    private javax.swing.JRadioButton rbtFemenino;
    private javax.swing.JRadioButton rbtMasculino;
    private javax.swing.JTabbedPane tbPaneOdontologo;
    private javax.swing.JTextField txtApellidoMaterno;
    private javax.swing.JTextField txtApellidoPaterno;
    private javax.swing.JTextField txtCMP;
    private javax.swing.JTextField txtCelular;
    private javax.swing.JTextField txtDireccion;
    private javax.swing.JTextField txtDni;
    private javax.swing.JTextField txtEdad;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtEspecialidad;
    private javax.swing.JTextField txtFacultad;
    private javax.swing.JTextField txtNacionalidad;
    private javax.swing.JTextField txtNombres;
    private javax.swing.JTextField txtTel;
    // End of variables declaration//GEN-END:variables
}
